package v1ch06.interfaces;

public class Employee implements Comparable<Employee> {
	private String name;
	private double salary;
	
	public Employee(String name, double salary) {
		this.name = name;
		this.salary = salary;
	}
	
	public String getName() {
		return name;
	}
	
	public double getSalary() {
		return salary;
	}
	
	public void raiseSalary(double byPercent) {
		double raise = salary * byPercent / 100;
		salary += raise;
	}
	
	/**
	 * 按薪金比较员工
	 *
	 * @param other 另一个Employee对象
	 * @return 如果该员工的薪水低于
	 * otherObject，如果工资相同，则为0，否则为正值
	 */
	public int compareTo(Employee other) {
		return Double.compare(salary, other.salary);
	}
}